package cn.darksoul3.springcloud.controller;

import cn.darksoul3.common.cons.SvcConst;
import cn.darksoul3.common.result.DataResult;
import cn.darksoul3.common.result.ObjectResult;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;


@Slf4j
@RestController
public class tok {

    private final RestTemplate rest;
    private final DiscoveryClient discoveryClient;

    @Autowired
    public tok(RestTemplate rest, DiscoveryClient discoveryClient) {
        this.rest = rest;
        this.discoveryClient = discoveryClient;
    }


    @GetMapping(value = "/tok")
    public ObjectResult tok(){
        log.info("this is tok");
        return rest.getForObject(SvcConst.TICK_SVC_ENDPOINT,ObjectResult.class);
    }

    @GetMapping(value = "/discovery")
    public ObjectResult discovery(){
        log.info("this is discovery");
        return ObjectResult.succeed(this.discoveryClient);
    }
}
